package com.zpark.serviceimpl;

import com.zpark.entity.User;
import com.zpark.dao.UserDao;
import com.zpark.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User login(String name,String password) {
        return userDao.selectUserByNameAndPassword(name,password);
    }

    @Override
    public User queryUserById(Integer id) {
        return userDao.selectUserById(id);
    }

    @Override
    public List<User> queryUserByPage(Integer offset, Integer limit, String column, Object value) {
        return userDao.selectUserByPage(offset-1,limit,column,value);
    }

    @Override
    public int queryUserCount(String column, String value) {
        return userDao.selectUserCount(column,value);
    }

    @Override
    public List<User> queryUserByIds(Integer[] ids) {
        return userDao.selectUserByIds(ids);
    }

    @Override
    public List<User> queryAllUser() {
        return userDao.selectAllUser();
    }

    @Override
    public int queryCountBySex(Integer value) {
        return userDao.selectCountBySex(value);
    }

    @Override
    public void register(User user) {
        userDao.insertUser(user);
    }

    @Override
    public void addAllUser(List<User> users) {
        userDao.insertAllUser(users);
    }

    @Override
    public void amendUser(User user) {
        userDao.updateUser(user);
    }

    @Override
    public void dropUserById(Integer id) {
        userDao.deleteUserById(id);
    }

    @Override
    public void dropUserByIds(Integer[] ids) {
        userDao.deleteUserByIds(ids);
    }
}
